package com.sun.task;

import com.sun.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class WebSocketTask {

    @Autowired
    private WebSocketServer webSocketServer;

    @Scheduled(cron = "0/15 * * * * ?")
    public void sendMessageToClient(){
        webSocketServer.sendAllClient("这是来自服务器的信息:" + new Date());
    }
}
